import { AxiosRequestConfig } from 'axios'
import serverApiUtils from '@/core/utils/serverApiUtils'
import lodash from 'lodash'
import { R } from '@/components/axios/interface'
import http from '@/components/axios/http'
import Oauth2RegisteredClientResponse from '@/core/oauth2/types/model/response/Oauth2RegisteredClientResponse'
import oauth2AdminApiConfig from '@/core/oauth2/generated/apiconfig/oauth2AdminApiConfig'

class Oauth2RegisteredClientServerApi {
	getByIds = (userToken: string, ids: string[]): Promise<R<Oauth2RegisteredClientResponse[]>> => {
		const config = lodash.merge(
			{
				params: { ids: ids },
				headers: serverApiUtils.addOnlyTokenHeader(userToken),
			} as AxiosRequestConfig,
			serverApiUtils.convertApiConfig(oauth2AdminApiConfig.oauth2RegisteredClient.list),
		)
		console.log(config)
		return http.post(config)
	}
}

const serverApi = new Oauth2RegisteredClientServerApi()
export default serverApi
